package com.itheima.mapper;

import com.itheima.pojo.Role;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

@Mapper
public interface UserMapper {
    @Select("select * from t_user where username = #{username}")
    User getByUsername(String username);

    @Select("SELECT r.*  FROM t_user_role ur LEFT JOIN t_role r ON r.id = ur.role_id  WHERE ur.user_id = #{userId}")
    Set<Role> getRolesByUserId(Integer id);
}
